package github.sf.fw.tools.db;


import github.sf.fw.tools.db.impl.doris.DorisDbOperation;
import github.sf.fw.tools.db.impl.mysql.MysqlDbOperation;
import github.sf.fw.tools.db.impl.nebula.NebulaDbOperation;
import github.sf.fw.tools.db.impl.neo4j.Neo4jDbOperation;
import github.sf.fw.tools.db.impl.oracle.OracleDbOperation;
import github.sf.fw.utils.StrUtil;

import java.util.Optional;

public class DBFactory {
    private final static String unknownType = "mysql";

    public static DbOperation getDbOperation(String type) {
        String dbType = Optional.ofNullable(type).orElse(unknownType);
        switch (dbType) {
            case "mysql":
                return new MysqlDbOperation();
            case "oracle":
                return new OracleDbOperation();
            case "doris":
                return new DorisDbOperation();
            case "neo4j":
                return new Neo4jDbOperation();
            case"nebula":
                return new NebulaDbOperation();
            default:
                throw new UnsupportedOperationException(StrUtil.format("not support {}", type));
        }
    }
}
